package com.qf.boot2202day03.controller;

import com.qf.boot2202day03.annotation.NullValidation;
import com.qf.boot2202day03.vo.HelloVo;
import com.qf.boot2202day03.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/hello")
public class HelloController {


    @GetMapping("/test1")
    public ResultVo test1(@Valid HelloVo helloVo){  // 使用@Valid  开启参数校验功能

        System.out.println(helloVo);

        return new ResultVo(1,"ok");
    }


    @PostMapping("/test2")
    public ResultVo test2(@Valid @RequestBody HelloVo helloVo){  // 使用@Valid  开启参数校验功能

        System.out.println(helloVo);

        return new ResultVo(1,"ok");
    }

    @NullValidation
    @GetMapping("/test3")
    public ResultVo test3(String name,Integer id){  // 使用@Valid  开启参数校验功能

        System.out.println(name);

        System.out.println(id);

        return new ResultVo(1,"ok");
    }


}
